const path = require('path')
const VueLoaderPlugin = require('vue-loader/lib/plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const webpack = require('webpack')
const { DefinePlugin } = require('webpack')


module.exports = {
  mode: 'none',
  entry: './src/main.js',
  output: {
    filename: 'bundle.js',
    path: path.join(__dirname, 'dist'),
  },
  module: {
    rules: [
      {
        test: /\.less$/,
        use: [
          'style-loader',
          'css-loader',
          'less-loader'              
        ]
      },
      {
        test: /\.css$/,
        use: [
          'vue-style-loader',
          'css-loader'
        ]
      },
      {
        test: /\.(js|vue)$/,
        exclude: [
          /node_modules/
        ],
        use: 'eslint-loader',
        enforce: 'pre'
      },
      {
        test: /\.js$/,
        exclude: [
          /node_modules/
        ],
        use: {
          loader: 'babel-loader',
          options: {
            presets: ['@babel/preset-env']
          }
        }
      },
      {
        test: /\.vue$/,
        use: 'vue-loader'
      },
      {
        test: /\.png$/,
        use: {
          loader: 'url-loader',
          options: {
            limit: 3000,
            name: '[name].[hash:8].[ext]',
            outputPath: 'assets/',
            esModule: false  //// 4.2版本file-loader的时候是没事的，现在file-loader升级到5.0 需要加上
          }
        }
      }
    ]
  },
  plugins: [
    new VueLoaderPlugin(),
    new HtmlWebpackPlugin({
      title: 'my webpack',
      template: './public/index.html',
      filename: 'index.html',
      chunks: ['main']
    }),
    new DefinePlugin({
      BASE_URL: '"public/"'
    })
  ]
}